package com.bdqn.demo.service.impl;


import com.bdqn.demo.dao.UserMapper;
import com.bdqn.demo.pojo.User;
import com.bdqn.demo.service.UserService;
import org.apache.ibatis.session.SqlSession;
import com.bdqn.demo.util.MybatisUtil;
import java.util.List;

public class UserServiceImpl implements UserService {
    SqlSession sqlSession= com.bdqn.demo.util.MybatisUtil.getSqlSession();
    @Override
    public int loginUser(User user) {
        int result=0;
        User user1=sqlSession.getMapper(UserMapper.class).selectUser(user);
        MybatisUtil.closeSqlSession(sqlSession);
        if(user1!=null){
            result=1;
        }
        return result;
    }

    @Override
    public int userUser(User user) {
        int result=sqlSession.getMapper(UserMapper.class).userUser(user);
        MybatisUtil.closeSqlSession(sqlSession);
        return result;
    }

    @Override
    public List<User> selectUser() {
        List<User> list=sqlSession.getMapper(UserMapper.class).User();
        MybatisUtil.closeSqlSession(sqlSession);
        return list;
    }

    @Override
    public int insertUser(User user) {
        int result=sqlSession.getMapper(UserMapper.class).insertUser(user);
        MybatisUtil.closeSqlSession(sqlSession);
        return result;
    }

    @Override
    public int updateUser(User user) {
        int result=sqlSession.getMapper(UserMapper.class).updateUser(user);
        MybatisUtil.closeSqlSession(sqlSession);
        return result;
    }

    @Override
    public int deleteUser(User user) {
        int result=sqlSession.getMapper(UserMapper.class).deleteUser(user);
        MybatisUtil.closeSqlSession(sqlSession);
        return result;
    }
}
